<?php
//当前控制器的命名空间，对应Application\Admin\Controller目录
namespace Admin\Controller;
//引入的命名空间
use Think\Controller;
//Admin模块Index控制器
class FormController extends Controller {


 //验证码生成
    public function verify_c(){  
        $Verify = new \Think\Verify();  
        $Verify->fontSize = 18;  
        $Verify->length   = 4;  
        $Verify->useNoise = false;  
        $Verify->codeSet = 'abcdefghij';  
        $Verify->imageW = 130;  
        $Verify->imageH = 50;  
        //$Verify->expire = 600;  
        $Verify->entry();  
    }

     //俱乐部管理员 登录
    public function login_admin($adnameA = '', $passwordA = ''){
    $adnameA = $_POST['adnameA'];
    $passwordA = $_POST['passwordA'];
    $verify = $_POST['verify'];
    //验证码检测
    if(!check_verify($verify)){  
    $this->error("验证码输错了哦！");
    }
    //验证中...
    $Data = M('Admin');
    $result = $Data->where("adname='" . $adnameA . "' AND password='" . $passwordA . "'")->find();

    if($result){
        session('adnameA',$adnameA);
        
        $this->success('登录成功！',U('/Admin/index'));//若提交完成则显示成功消息
    }else{
        $this->error('用户名或密码错误！');//否则提示
    }
    }
    //俱乐部管理员 退出登录
    public function logout(){
        if(isset($_SESSION['adnameA'])){
            session('adnameA',null);
            session('[destroy]');
            $this->success('用户已退出！', U('/Admin/Form/login'));
        }else{
            $this->redirect('/Admin/Form/login');
        }
    }

    //注册
public function Register()
     {
         $this->display();
     }


    public function regpost(){
        $adname = $_POST['adname'];
        
       
        $password = $_POST['password'];
       
        $club_id = 0;

        $reg = D('admin');

        if ($reg->create()) 
        {
            if (false !== $reg->add()) {
                //echo $user->getLastSql();
                $this->success('添加成功！', '../Form/login');
            }
            else
            {
                $this->error('添加失败，数据错误','../Form/login');
            }
        }
            $this->display(); 
    }

    

    
    
    
}